package cn.zjyj.module.zjyj.dal.mysql.supplier;

import cn.zjyj.framework.common.common.pojo.PageResult;
import cn.zjyj.framework.datasource.mybatis.core.query.LambdaQueryWrapperX;
import cn.zjyj.framework.datasource.mybatis.core.mapper.BaseMapperX;
import cn.zjyj.module.zjyj.dal.dataobject.supplier.SupplierDO;
import org.apache.ibatis.annotations.Mapper;
import cn.zjyj.module.zjyj.controller.admin.supplier.vo.*;

/**
 * 供应商 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface SupplierMapper extends BaseMapperX<SupplierDO> {

    default PageResult<SupplierDO> selectPage(SupplierPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SupplierDO>()
                .betweenIfPresent(SupplierDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(SupplierDO::getName, reqVO.getName())
                .eqIfPresent(SupplierDO::getContacts, reqVO.getContacts())
                .eqIfPresent(SupplierDO::getPhone, reqVO.getPhone())
                .eqIfPresent(SupplierDO::getEmail, reqVO.getEmail())
                .eqIfPresent(SupplierDO::getRemark, reqVO.getRemark())
                .eqIfPresent(SupplierDO::getStatus, reqVO.getStatus())
                .eqIfPresent(SupplierDO::getTaxpayerNumber, reqVO.getTaxpayerNumber())
                .eqIfPresent(SupplierDO::getOpenAccountNumber, reqVO.getOpenAccountNumber())
                .eqIfPresent(SupplierDO::getBankAccountNumber, reqVO.getBankAccountNumber())
                .likeIfPresent(SupplierDO::getBankAccountName, reqVO.getBankAccountName())
                .eqIfPresent(SupplierDO::getBankAccountAddress, reqVO.getBankAccountAddress())
                .orderByDesc(SupplierDO::getId));
    }

}